<!--
 * @Author: anshengtyp
 * @Date: 2024-03-22 10:43:09
 * @LastEditTime: 2025-01-15 10:07:01
 * @LastEditors: typ
 * @Description: 照片集
-->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入项目名称" clearable style="width: 200px"
          @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item label="行政区" prop="areaCode">
        <el-select filterable style="width: 100%" v-model="queryParams.areaCode" placeholder="请选择">
          <el-option v-for="dict in sys_hn_areacode" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="生成时间" prop="createTime">
        <el-date-picker type="date" placeholder="请选择" :size="'small'" v-model="queryParams.createTime" clearable
          style="width: 200px" value-format="YYYY-MM-DD" @change="getList" />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select type="date" placeholder="请选择" :size="'small'" v-model="queryParams.status" clearable
          style="width: 200px" @change="getList">
          <el-option v-for="dict in sys_publish_status" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="数据来源" prop="dataFrom">
        <el-select filterable style="width: 100%" v-model="queryParams.dataFrom" placeholder="请选择" @change="getList"
          clearable>
          <el-option v-for="dict in data_sours" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button :disabled="progressLoading" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDeletes">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="Upload" @click="handlerAddMore">批量导入</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange"
      :default-sort="{ prop: 'createTime', order: 'descending' }">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" type="index" width="90" />
      <el-table-column label="项目编号" align="center" prop="dataId" />
      <el-table-column label="项目名称" align="center" prop="name" />
      <el-table-column label="行政区" align="center">
        <template #default="scope">
          <dict-tag :options="sys_hn_areacode" :value="scope.row.areaCode" />
        </template>
      </el-table-column>
      <el-table-column label="位置" align="center" prop="location" />
      <el-table-column label="状态" align="center" prop="location">
        <template #default="{ row }">
          <dict-tag :options="sys_publish_status" :value="row.status" />
        </template>
      </el-table-column>
      <el-table-column label="经度" align="center" prop="longitude" />
      <el-table-column label="纬度" align="center" prop="latitude" />
      <el-table-column label="数据来源" align="center" prop="dataFrom">
        <template #default="scope">
          <dict-tag :options="data_sours" :value="scope.row.dataFrom" />
        </template>
      </el-table-column>
      <el-table-column label="生成时间" align="center" prop="createTime" sortable width="160" />
      <el-table-column label="操作" width="340" align="center" class-name="small-padding fixed-width"
        style="display: flex; align-items: center; justify-content: center">
        <template #default="scope">
          <el-button :disabled="progressLoading" link type="primary" icon="Edit"
            @click="handleUpdate(scope.row)">修改</el-button>
          <el-button link type="primary" icon="Star" @click="manageHandler(scope.row)">管理</el-button>
          <el-button link type="primary" icon="View" @click="viewgroup(scope.row)">预览组</el-button>
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
          <!--管理员权限 -->
          <el-dropdown size="small" v-hasPermi="['*:*:*']">
            <el-link :underline="false" type="primary" style="margin-left: 12px">
              更多<el-icon class="el-icon--right" size="small"><arrow-down /></el-icon>
            </el-link>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click="downloadGeoJson(scope.row)">下载geoJson</el-dropdown-item>
                <el-dropdown-item @click="downloadPic(scope.row)">下载全景照片</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改岗位对话框 -->
    <el-dialog :title="title" v-model="open" width="40%" draggable>
      <el-form ref="postRef" :model="form" label-width="120px">
        <el-form-item label="项目编号" prop="dataId" :rules="{
          required: true,
          message: `请输入项目编号`,
          trigger: 'blur',
        }">
          <el-input v-model="form.dataId" placeholder="请输入项目编号" clearable />
        </el-form-item>
        <el-form-item label="项目名称" prop="name" :rules="{
          required: true,
          message: `请输入项目名称`,
          trigger: 'blur',
        }">
          <el-input v-model="form.name" placeholder="请输入项目名称" clearable />
        </el-form-item>
        <el-form-item label="行政区" prop="areaCode" porps="areaCode"
          :rules="{ required: true, message: `请选择行政区`, trigger: 'blur' }">
          <el-select style="width: 100%" v-model="form.areaCode" placeholder="请选择" clearable>
            <el-option v-for="dict in sys_hn_areacode" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="位置" prop="location" :rules="{ required: true, message: `请输入位置`, trigger: 'blur' }">
          <el-input v-model="form.location" placeholder="请输入位置" clearable />
        </el-form-item>
        <el-form-item label="经度" prop="longitude" :rules="{ required: true, message: `请输入经度`, trigger: 'blur' }">
          <el-input v-model="form.longitude" placeholder="请输入经度" clearable />
        </el-form-item>
        <el-form-item label="纬度" porp="latitude" :rules="{ required: true, message: `请输入纬度`, trigger: 'blur' }">
          <el-input v-model="form.latitude" placeholder="请输入纬度" clearable />
        </el-form-item>
        <el-form-item label="数据来源" prop="dataFrom">
          <el-select filterable style="width: 100%" v-model="form.dataFrom" placeholder="请选择" @change="changeSource"
            clearable>
            <el-option v-for="dict in data_sours" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>

        <template v-for="item in form.extraProperties" :key="item.dictValue">
          <el-form-item v-if="item.remark?.type === 'string'" :label="item.dictLabel" :prop="item.dictValue" :rules="{
            required: item.remark?.required,
            message: `请输入${item.dictLabel}`,
            trigger: 'blur',
          }">
            <el-input v-model="item.value" placeholder="请输入" clearable />
          </el-form-item>
          <el-form-item v-if="item.remark?.type === 'number'" :label="item.dictLabel" :prop="item.dictValue" :rules="{
            required: item.remark?.required,
            message: `请输入${item.dictLabel}`,
            trigger: 'blur',
          }">
            <el-input-number style="width: 100%" :min="0" v-model="item.value" placeholder="请输入" clearable />
          </el-form-item>
        </template>

        <el-form-item label="缩略图">
          <el-upload accept=".png,.jpg,.jpeg,.webp" :file-list="abbFileList" action=" #" list-type="picture-card"
            :auto-upload="false" :on-change="abbHandleChange">
            <el-icon>
              <Plus />
            </el-icon>
            <template #tip>
              <div class="el-upload__tip">
                只支持上传<span style="color: red">png、jpg、jpeg、webp</span>
                图片格式
              </div>
            </template>
          </el-upload>
        </el-form-item>

        <el-form-item label="全景图" v-if="!form.id">
          <el-upload style="width: 100%" :auto-upload="false" v-model:file-list="fileList" action="#" multiple
            accept=".png,.jpg,.jpeg,.webp" :on-change="handleChange">
            <el-button type="primary">选取文件</el-button>
            <template #tip>
              <div class="el-upload__tip">
                只支持上传<span style="color: red">png、jpg、jpeg、webp</span>
                图片格式
              </div>
            </template>
          </el-upload>
        </el-form-item>

        <el-form-item label="geoJson">
          <el-upload accept=".json" ref="upload" style="width: 100%" :auto-upload="false" :file-list="geoFileList"
            action="#" :limit="1" :on-change="geoHandleChange" :on-exceed="handleExceed">
            <el-button type="primary">选取文件</el-button>
            <template #tip>
              <div class="el-upload__tip">
                只支持<span style="color: red">json</span>格式文件
              </div>
            </template>
          </el-upload>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="cancel">取 消</el-button>
          <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 批量添加 -->
    <el-dialog :title="batchTitle" v-model="batchOpen" width="400px" append-to-body @close="batchClose">
      <input type="file" id="filepicker" name="fileList" webkitdirectory @change="handleFileChange" />
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="batchClose">取 消</el-button>
          <el-button type="primary" @click="submitFileForm">确 定</el-button>
        </div>
      </template>
    </el-dialog>

    <progressBar v-if="progressLoading" :progress="progress"></progressBar>
  </div>
</template>

<script setup name="PhotoGallery">
import { genFileId, ElLoading } from "element-plus";
import {
  getGatherList,
  addGather,
  addFolderBatchAdd,
  updateGather,
  deleteGather,
  deleteGathers,
  getGatherDetails,
} from "@/api/gather";
import { splitImage } from "@/api/720.js";
import { listData } from "@/api/system/dict/data";
import { fileUploadMore, compressImages, fileUploadOne } from "@/utils/ruoyi";
import { ref } from "vue";
import useUserStore from '@/store/modules/user'

const { proxy } = getCurrentInstance();
const { sys_hn_areacode, data_sours, sys_publish_status } = proxy.useDict(
  "sys_hn_areacode",
  "data_sours",
  "sys_publish_status"
);
import progressBar from "../../components/progressBar";
const router = useRouter();

const postList = ref([]);
const open = ref(false);
let loading = ref(true);
let progressLoading = ref(false);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
let fileList = ref([]);
let abbFileList = ref([]);
let geoFileList = ref([]);
let batchFileList = ref([]);
let batchOpen = ref(false);
let batchTitle = ref("批量导入");
let progress = ref(0);
const data = reactive({
  form: {
    extraProperties: [],
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    name: undefined,
    areaCode: undefined,
    createTime: null
  },
});
const jsonFileList = ref([]);
const thumIMageList = ref([]);
const fullImageList = ref([]);
const formData = ref([]);

const { queryParams, form } = toRefs(data);

const cardShow = computed(() => {
  return abbFileList.value.length >= 1 ? "none" : "inline-flex";
});

/** 查询列表 */
function getList() {
  loading.value = true;
  getGatherList(queryParams.value).then((response) => {
    postList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
}
/** 表单重置 */
function reset() {
  form.value.extraProperties = [];
  abbFileList.value = [];
  fileList.value = [];
  geoFileList.value = [];
  form.value = {
    name: undefined,
    areaCode: undefined,
  };
  proxy.resetForm("postRef");
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}
/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}
/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加项目";
}
/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const id = row.id || ids.value;
  getGatherDetails(id).then((response) => {
    form.value = response.data;
    if (form.value.dataFrom) {
      form.value.extraProperties = JSON.parse(form.value.extraProperties);
    }
    if (response.data.geoJson) {
      geoFileList.value = [
        {
          ...response.data.geoJson,
          name:
            response.data.geoJson.name.indexOf("/geojson/") > -1
              ? response.data.geoJson.name.split("/").at(-1)
              : response.data.geoJson.name,
          url: response.data.geoJson.id,
          annexId: response.data.geoJson.id,
        },
      ];
    }
    if (response.data.thumb) {
      abbFileList.value = [response.data.thumb].map((item) => {
        return {
          ...item,
          annexId: item.id,
          url: import.meta.env.VITE_APP_PIC_BASE_API + item.path,
        };
      });
    }
    open.value = true;
    title.value = "修改项目";
  });
}
/** 提交按钮 */
function submitForm() {
  // if (!form.value.id && !fileList.value.length) return proxy.$modal.msgError("请上传全景图!");
  //if (!abbFileList.value.length) return proxy.$modal.msgError("请上传缩略图!");
  proxy.$refs["postRef"].validate(async (valid) => {
    try {
      if (valid) {
        progressLoading.value = true;
        open.value = false;
        // 初始化进度
        let totalSteps = 5;
        let completedSteps = 0;
        // 缩略图上传
        if (abbFileList.value.length && !abbFileList.value[0]?.annexId) {
          const res = await fileUploadOne(abbFileList.value[0]);
          form.value.thumbId = res.id;
        }
        completedSteps++;
        progress.value = Math.round((completedSteps / totalSteps) * 100);
        // 过滤没有上传图片
        const noUpload = fileList.value.filter((item) => !item.annexId);
        let compressList = []; // 压缩返回的图片
        // 图片压缩
        if (noUpload.length > 0) {
          compressList = await compressImages(noUpload);
        }
        completedSteps++;
        progress.value = Math.round((completedSteps / totalSteps) * 100);
        // 材料上传
        let res = null;
        let compressRes = null;
        let partition = [];
        if (noUpload.length > 0) {
          res = await fileUploadMore(noUpload);
          // 进行后端分割
          for (const url of res.fileNames) {
            let result = await splitImage("url=" + url); // 分割图片
            partition.push(result.data);
          }
        }
        completedSteps++;
        progress.value = Math.round((completedSteps / totalSteps) * 100);
        if (compressList.length > 0) {
          compressRes = await fileUploadMore(compressList);
        }
        completedSteps++;
        progress.value = Math.round((completedSteps / totalSteps) * 100);
        if (res) {
          form.value.pictures = res.attachmentIds.map((item, index) => {
            return {
              groupId: form.value?.id,
              annexId: item,
              pictureType: "0", // 平面模式
              thumbId: compressRes.attachmentIds[index],
              name: res.originalFilenames[index].split(".")[0],
              tilesValue: partition[index],
              detailsValue: {
                // 设置720配置默认值
                defaultHorizontalAngle: 0,
                defaultVerticalAngle: 0,
                defaultZoomLevel: 50,
                minViewAngle: 30,
                maxViewAngle: 90,
                correctRoll: 0,
                correctTilt: 0,
                correctPan: 0,
                enableFisheye: false,
                enableCtrlZoom: false,
                enableMouseInteraction: true,
                enableMouseWheel: true,
                moveButton: true,
                zoomButton: true,
                downloadButton: false,
                fullscreenButton: true,
              },
            };
          });
        }
        const geoNoUpload = geoFileList.value.filter((item) => !item.annexId);
        if (geoNoUpload.length > 0) {
          let geores = await fileUploadOne(geoNoUpload[0]);
          form.value.geoJsonId = geores.id;
        }

        completedSteps++;
        progress.value = Math.round((completedSteps / totalSteps) * 100);

        form.value.extraProperties = JSON.stringify(form.value.extraProperties);
        // 清空geojson文件
        if (geoFileList.value.length === 0) {
          form.value.geoJsonId = null;
        }
        if (form.value.id != undefined) {
          updateGather(form.value).then((response) => {
            proxy.$modal.msgSuccess("修改成功");
            completedSteps = 5;
            progress.value = Math.round((completedSteps / totalSteps) * 100);
            progressLoading.value = false;
            cancel();
            getList();
          });
        } else {
          form.value.pictures;
          addGather(form.value).then((response) => {
            proxy.$modal.msgSuccess("新增成功");
            completedSteps = 5;
            progress.value = Math.round((completedSteps / totalSteps) * 100);
            progressLoading.value = false;
            cancel();
            getList();
          });
        }
      }
    } catch (error) {
      console.log('error', error)
    }
  });
}

async function changeSource(value) {
  const { rows } = await listData({ dictType: value + "_kz" });
  form.value.extraProperties = rows.map((item) => {
    return {
      dictType: item.dictType,
      dictValue: item.dictValue,
      dictLabel: item.dictLabel,
      value: "",
      remark: item.remark && JSON.parse(item.remark),
    };
  });
}
function abbHandleChange(file, fileList) {
  abbFileList.value = fileList;
}

// 管理照片
function manageHandler(row) {
  // 跳转
  router.push({ path: "/management720", query: { groupId: row.id } });
}
function viewgroup(row) {
  let url = `/groupview?groupId=${row.id}`;
  window.open(url, "_blank");
}
/** 删除按钮操作 */
function handleDelete(row) {
  const permissions = useUserStore().permissions;
  let isdelete = permissions.includes('*:*:*'); // 管理员
  proxy.$modal
    .confirm(`是否确认删除名称为"${row.name}"的数据项？`)
    .then(function () {
      return deleteGather(row.id, isdelete);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch((err) => {
      console.log('err', err)
    });
}
/** 批量删除按钮操作 */
function handleDeletes() {
  const permissions = useUserStore().permissions;
  let isdelete = permissions.includes('*:*:*'); // 管理员
  proxy.$modal
    .confirm(`是否确认删除选中的数据项？`)
    .then(function () {
      return deleteGathers(ids.value, isdelete);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch((err) => {
      console.log('err', err)
    });
}

function handleExceed(files) {
  proxy.$refs["upload"].clearFiles();
  const file = files[0];
  file.uid = genFileId();
  proxy.$refs["upload"].handleStart(file);
}

function handleChange(file, filelist) {
  fileList.value = filelist;
}

function geoHandleChange(file, filelist) {
  geoFileList.value = filelist;
}

function handlerAddMore() {
  batchOpen.value = true;
}

function batchClose() {
  document.getElementById("filepicker").value = "";
  batchOpen.value = false;
  batchFileList.value = [];
}

// 判断是否为图片文件的辅助函数
function isImageFile(filename) {
  return /\.(jpg|jpeg|png|gif)$/i.test(filename);
}
function handleFileChange(event) {
  for (const file of event.target.files) {
    // 如果是文件夹或者不符合条件的文件名则跳过
    const fileName = file.name;
    const path = file.webkitRelativePath;
    if (path.indexOf(".DS_Store") === -1) {
      if (path.indexOf("geojson") > -1) {
        file.folder = path;
        jsonFileList.value.push(file);
      } else if (isImageFile(fileName) && path.indexOf("thumbnail") > -1) {
        // 缩略图
        file.folder = path;
        thumIMageList.value.push(file);
      } else if (isImageFile(fileName) && path.indexOf("picture") > -1) {
        // 全景照片
        file.folder = path;
        fullImageList.value.push(file);
      } else {
        const fileReader = new FileReader();
        fileReader.onload = async function (res) {
          formData.value = JSON.parse(res.target.result);
        };
        fileReader.readAsText(file);
      }
    }
  }
}

// 通用的批量请求函数
async function batchRequest(promiseCreator, items, batchSize) {
  const results = [];
  for (let i = 0; i < items.length; i += batchSize) {
    const batch = items.slice(i, i + batchSize);
    const batchResults = await Promise.all(batch.map(promiseCreator));
    results.push(...batchResults);
  }
  return results;
}


// 文件上传函数
async function fileUploadOneWrapper(file) {
  return fileUploadOne(file);
}

// 图片分割函数
async function splitImageWrapper(url) {
  return splitImage(url).then(result => result.data);
}

// 添加文件夹函数
async function addFolderBatchAddWrapper(item) {
  return addFolderBatchAdd(item);
}


async function submitFileForm() {
  let downloadLoadingInstance = ElLoading.service({
    text: "正在处理文件，请稍候",
    background: "rgba(0, 0, 0, 0.7)",
  });

  try {
    let partition = [];
    let compressRes = [];
    let masteRes = [];
    let thumbimage = [];
    let geojson = [];

    // 上传缩略图
    if (thumIMageList.value?.length) {
      thumbimage = await fileUploadMore(thumIMageList.value);
    }

    // 上传geojson文件
    if (jsonFileList.value?.length) {
      geojson = await fileUploadMore(jsonFileList.value);
    }

    // 上传全景照片
    if (fullImageList.value?.length) {
      // 前端压缩
      let compressList = await compressImages(fullImageList.value);

      // 压缩图片上传
      if (compressList.length) {
        compressRes = await batchRequest(fileUploadOneWrapper, compressList, 5);
      }

      // 上传原图
      if (fullImageList.value.length) {
        masteRes = await batchRequest(fileUploadOneWrapper, fullImageList.value, 5);
      }

      // 进行后端分割
      if (masteRes.length) {
        const splitImageUrls = masteRes.map(item => "url=" + item.fileName);
        partition = await batchRequest(splitImageWrapper, splitImageUrls, 5);
      }
    }

    // 处理 formData 并分批发送请求
    const formDataWithAttachments = formData.value.map(item => {
      if (geojson.length) {
        const geoIndex = geojson.originalFilenames.findIndex(
          (x) => x.indexOf(item.geoJsonPath) > -1
        );
        item.geoJsonId = geojson.attachmentIds[geoIndex];
      }

      if (thumbimage.length) {
        const themIndex = thumbimage.originalFilenames.findIndex(
          (x) => x.indexOf(item.thumbnailPath) > -1
        );
        item.thumbId = thumbimage.attachmentIds[themIndex];
      }

      if (masteRes && item.pictures) {
        item.pictures.forEach((element) => {
          const index = masteRes.findIndex(i => i.displayName.indexOf(element.path) > -1);
          element.annexId = masteRes[index].id;
          element.thumbId = compressRes[index].id;
          if (element.name === "") {
            // 设置默认值
            element.name = masteRes[index].displayName.split("/").at(-1);
          }
          element.tilesValue = partition[index];
          // 添加默认值
          if (element.detailsValue === null) {
            element.detailsValue = {};
          }
          Object.assign(element.detailsValue, {
            defaultHorizontalAngle: 0,
            defaultVerticalAngle: 0,
            defaultZoomLevel: 50,
            minViewAngle: 30,
            maxViewAngle: 90,
            correctRoll: 0,
            correctTilt: 0,
            correctPan: 0,
            enableFisheye: false,
            enableCtrlZoom: false,
            enableMouseInteraction: true,
            enableTouchInteraction: false,
            enableNorthArrow: true,
            enableMouseWheel: true,
            moveButton: true,
            enableZoomControl: false,
            zoomButton: true,
            downloadButton: false,
            fullscreenButton: true,
          });
        });
      }
      return item;
    });

    await batchRequest(addFolderBatchAddWrapper, formDataWithAttachments, 5);

    proxy.$modal.msgSuccess("批量导入成功");
    batchClose();
    getList();
    downloadLoadingInstance.close();
  } catch (error) {
    console.log(error);
    proxy.$modal.msgError(error);
    downloadLoadingInstance.close();
  }
}


const downloadGeoJson = (row) => {
  if (!row.geoJson?.path) return proxy.$modal.msgWarning("没有上传geonJson文件");
  let a = document.createElement("a");
  a.href = import.meta.env.VITE_APP_PIC_BASE_API + row.geoJson?.path;
  a.download = `${row.name}-geojson文件.json`;
  a.style.display = "none";
  document.body.appendChild(a);
  a.click();
  a.remove();
};
function downloadPic(row) {
  proxy.$download.zip(`/picture/group/downLoadCollectionImages/${row.id}`, `${row.name}.zip`);
}
getList();
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__body {
  max-height: 80vh;
  overflow: auto;

  .el-upload-list__item-preview {
    display: none !important;
  }

  .el-upload--picture-card {
    display: v-bind(cardShow);
  }
}

::v-deep .cell {
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
